package com.googlecode.vmock.matchers;

import com.googlecode.vmock.matchers.ranking.MatcherRanking;

/**
 * Convenient abstract class which makes a {@link Matcher} comparable through the {@link MatcherRanking}.
 * <p>
 * The ranking of a matcher is usually initialized in a static initializer of a matcher's class. For example:
 * 
 * <pre>
 * <code>
 * public class MyMatcher extends AbstractMatcher {
 *     static {
 *         MatcherRanking.setRanking(MyMatcher.class, 123);
 *     }
 * }
 * </code>
 * </pre>
 * 
 * @author marcin.jagus
 */
public abstract class AbstractMatcher implements Matcher {

    /**
     * Compares this matcher to another matcher based on a priority values defined in {@link MatcherRanking}.
     */
    @Override
    public int compareTo(Matcher o) {
        return MatcherRanking.compare(this.getClass(), o.getClass());
    }

}
